<?php
if ( !defined('IN_SEC') ){exit();}
?>
<?php include template("admin_header");?>
                <div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
<?php include template("admin_breadcrumb");?>
					</div>

					<div class="page-content">
						<div class="page-header">
							<h1><?php echo $_G['admincp']['actname']; ?><small><i class="icon-double-angle-right"></i><?php echo $_G['admincp']['optname']; ?></small></h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<div class="row-fluid">
									<div class="span12">
										<div class="widget-box">
											<div class="widget-header widget-header-blue widget-header-flat">
												<h4 class="lighter">发送短信</h4>
											</div>

											<div class="widget-body">
												<div class="widget-main">
													<div class="step-content row-fluid position-relative" id="step-container">
                                                        <form class="form-horizontal" action="?action=customer&operation=sms_market" id="validation-form" method="post">
                                                    	<div class="row">
													<div class="col-xs-12 col-sm-12">
														<div class="form-group">
															<div class="col-xs-12 col-sm-12">
                                                                <input type="text" name="mobiles" id="form-field-tags" value="" placeholder="输入手机号码" />
															</div>
														</div>

														<div class="space-4"></div>

														<div class="form-group">
															<div class="col-xs-12 col-sm-12">
																<div class="widget-box col-sm-12">
																	<div class="widget-header widget-header-small header-color-green"></div>
																	<div class="widget-body">
																			<div class="widget-main no-padding">
																				<textarea class="span12" name="content" data-provide="markdown" rows="10"></textarea>
																			</div>
                                                                            <div class="widget-toolbox padding-4 clearfix">
                                                                                <div class="btn-group pull-right">
                                                                                    <button class="btn btn-sm btn-success">
                                                                                        <i class="icon-save bigger-125"></i>发送
                                                                                    </button>
                                                                                </div>
                                                                            </div>
																		</div>
																	</div>
															</div>
														</div>
													</div>
												</div>
														</form>
													</div>
												</div><!-- /widget-main -->
											</div><!-- /widget-body -->
										</div>
									</div>
								</div>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
<?php include template("admin_footer");?>
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="/static/ace/assets/css/jquery-ui-1.10.3.custom.min.css" />
		<link rel="stylesheet" href="/static/ace/assets/css/select2.css" />
		<!-- page specific plugin scripts -->

		<script type="text/template" id="customer-template">
                                                                                <tr>
                                                                                    <td class="">{name}</td>
                                                                                    <td class="hidden-480">{admin}</td>
                                                                                </tr>
        </script>

		<script src="/static/ace/assets/js/markdown/markdown.min.js"></script>
		<script src="/static/ace/assets/js/markdown/bootstrap-markdown.min.js"></script>

		<script src="/static/ace/assets/js/fuelux/fuelux.wizard.min.js"></script>
		<script src="/static/ace/assets/js/jquery.validate.min.js"></script>
		<script src="/static/ace/assets/js/additional-methods.min.js"></script>
		<script src="/static/ace/assets/js/jquery.maskedinput.min.js"></script>
		<script src="/static/ace/assets/js/select2.min.js"></script>
		<script src="/static/ace/assets/js/bootstrap-tag.min.js"></script>
		<script type="text/javascript">
			D.Main = {
				init : function(){
					$('#province').change(function(){
						var pid = $(this).val();
						var html = '<option value="0">选择城市</option>';
						if( pid ){
							$('#city').html(html + '<option disabled>数据加载中</option>').select2({allowClear:true});
							D.ajax.get('?action=customer&operation=edit&act=public_get_city&dataid=' + pid, function(json){
								if ( json.data ){
									$.each(json.data, function(i, n){
										if ( n.id && n.name ){
											html += '<option value="'+n.id+'">'+n.name+'</option>';
										}
									});
								}
								$('#city').html(html).select2({allowClear:true});
							});
						}else{
							$('#city').html(html).select2({allowClear:true});
						}
					});
<?php if(!$customer){?>
					$('#name').on('blur', function(){
						var box = $(this);
						var last = $(this).attr('last');
						var name = box.val();
						box.attr('last', name);
						if( name && last != name ){
							$('.check-loading').removeClass('hide');
							box.attr('readonly', true);
	
							D.ajax.get('?action=customer&operation=edit&act=search&name=' + name, function(json){
								var html = '';
								if( !json.error || json.type == 'data' ){
									if( json.data && json.data.customers ){
										$.each(json.data.customers, function(i, n){
											var user = json.data.admins[n.adminid];
											if( user ){
												var company = json.data.companys[user.companyid];
												if( company ){
													var data = {
														name : n.name,
														admin : '[' + company.name + '] ' + (user.realname ? user.realname : user.username)
													};
													html += D.T.selector('#customer-template', data);
												}
											}
										});
									}
								}
								if( !html ){
									$('.customers-list').addClass('hide');
								}else{
									$('.customers-list').removeClass('hide').hide().slideDown();
									$('.customers-list .table tbody').html(html);
								}
								box.removeAttr('readonly');
								$('.check-loading').addClass('hide');
							});
						}
						if( !name ){
							$('.customers-list').addClass('hide');
						}
					});
<?php }?>
				}
			}
			jQuery(function($) {
				$('[data-rel=tooltip]').tooltip();

				$(".select2").css('width','200px').select2({allowClear:true}).on('change', function(){
					$(this).closest('form').validate().element($(this));
				}); 
				$('.select-100').css('width', 100);
				var tag_input = $('#form-field-tags');
				if(! ( /msie\s*(8|7|6)/.test(navigator.userAgent.toLowerCase())) ) {
					tag_input.tag({
						placeholder:tag_input.attr('placeholder'),
						//enable typeahead by specifying the source array
						source: null
					  }
					);
				}else {
					//display a textarea for old IE, because it doesn't support this plugin or another one I tried!
					tag_input.after('<textarea id="'+tag_input.attr('id')+'" name="'+tag_input.attr('name')+'" rows="3">'+tag_input.val()+'</textarea>').remove();
					//$('#form-field-tags').autosize({append: "\n"});
				}
			});
		</script>
<style>
.tags{ width:100%;}
</style>
</body>
</html>
